package com.rede.didiok.user.modulelist.rank.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.common.utils.PageUtils;
import com.rede.didiok.common.utils.R;
import com.rede.didiok.user.modulelist.rank.entity.VoteCountEntity;
import com.rede.didiok.user.modulelist.rank.service.VoteCountService;


/**
 * 榜单成员拥有的投票数和点击数
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-07-20 22:09:24
 */
@RestController
@RequestMapping("rank/votecount")
public class VoteCountController {
    @Autowired
    private VoteCountService voteCountService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("rank:votecount:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = voteCountService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{countId}")
    // @RequiresPermissions("rank:votecount:info")
    public R info(@PathVariable("countId") Long countId){
		VoteCountEntity voteCount = voteCountService.getById(countId);

        return R.ok().put("voteCount", voteCount);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("rank:votecount:save")
    public R save(@RequestBody VoteCountEntity voteCount){
		voteCountService.save(voteCount);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("rank:votecount:update")
    public R update(@RequestBody VoteCountEntity voteCount){
		voteCountService.updateById(voteCount);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("rank:votecount:delete")
    public R delete(@RequestBody Long[] countIds){
		voteCountService.removeByIds(Arrays.asList(countIds));

        return R.ok();
    }

}
